package org.github.socket.protocol.ykq.util;

import cn.hutool.core.util.ArrayUtil;
import org.tinylog.Logger;

public class Util {
    public static boolean calculateChecksum(byte[] data, short dataLength, short segmentCheckDomain) {
        byte[] checkData = ArrayUtil.sub(data, 2, dataLength + 1);
        short check = CRC16Modbus.get(checkData);
        Logger.debug("帧校验域 check-> {} , segmentCheckDomain -> {} ", check, segmentCheckDomain);
        return check == segmentCheckDomain;
    }
}
